(deftemplate animal (slot nume)(slot sex)(slot inaltime))
(deftemplate arca (slot pozitie)(slot nume))

(assert(animal(nume soarece)(sex m)(inaltime 1)))
(assert(animal(nume soarece)(sex f)(inaltime 1)))
(assert(animal(nume veverita)(sex m)(inaltime 2)))
(assert(animal(nume veverita)(sex f)(inaltime 2)))
(assert(animal(nume pisica)(sex m)(inaltime 3)))
(assert(animal(nume pisica)(sex f)(inaltime 3)))
(assert(animal(nume caine)(sex m)(inaltime 5)))
(assert(animal(nume caine)(sex f)(inaltime 5)))
(assert(animal(nume vaca)(sex m)(inaltime 7)))
(assert(animal(nume vaca)(sex f)(inaltime 7)))
(assert(animal(nume elefant)(sex m)(inaltime 10)))
(assert(animal(nume elefant)(sex f)(inaltime 10)))

(defglobal ?*contor* = 1)
(defrule asezareArca
    ?id <- (animal (nume ?n) (inaltime ?i)) 
    =>
    (assert (arca (pozitie ?*contor*) (nume ?n)))
    (++ ?*contor*)
)
(run)
(facts)